package com.freecloud.javabasics.jvm;

/**
 * 虚拟机栈的StackOverflowError
 *
 * JVM参数：-Xms20M -Xmx20M -Xmn10M -Xss160k -verbose:gc -XX:+PrintGCDetails
 * @Author: maomao
 * @Date: 2019-11-12 09:48
 */
public class JVMStackSOF {

    private int count = 0;

    /**
     * 通过递归调用造成StackOverFlowError
     */
    public void stackLeak() {
        count++;
        stackLeak();
    }

    public static void main(String[] args) {
        JVMStackSOF oom = new JVMStackSOF();

        try {
            oom.stackLeak();
        }catch (Throwable e){
            System.out.println("stack count : " + oom.count);
            e.printStackTrace();
        }

    }

}
